package implementor;

import java.sql.Date;


import daoInterface.SellDao;
import dbhandeling.Crude;
import dto.Sell;
import dto.Sell;
import dto.SellerInfo;

public class SellImp  extends Crude implements SellDao
{
	String className = new Sell().getClass().getName();
	@Override
	public void add(Sell cat) throws Exception {
		super.insert(cat);
		
	}

	@Override
	public void update(Sell cat) throws Exception {
		super.update(className, "mCode", cat.getmCode(),"autoitemCode", cat.getAutoitemCode()+"");
		super.update(className, "discount", cat.getDiscount()+"","autoitemCode", cat.getAutoitemCode()+"");
		super.update(className, "SellQuant", cat.getSellQuant()+"","autoitemCode", cat.getAutoitemCode()+"");
		super.update(className, "taxCode", cat.getTaxCode()+"","autoitemCode", cat.getAutoitemCode()+"");
		
	}

	@Override
	public void delete(Sell cat) {
		// TODO Auto-generated method stub
		super.delete(className, "autoitemCode", cat.getAutoitemCode()+"");
		
	}

	@Override
	public Sell[] retrieveArray(String conditionField,
			String conditionValue) throws Exception {
		Object[] cat= super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		Sell[]s=new Sell[cat.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(Sell) cat[i];
		return s;
	}

	@Override
	public Sell[] retrieveAll() throws Exception {
		Object[] cat= super.retreiveAll(className);
		Sell[]s=new Sell[cat.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(Sell) cat[i];
		return s;
	}

	@Override
	public Sell retrieve(String conditionField,
			String conditionValue) throws Exception {
		Sell cat=(Sell) super.retreive(className, conditionField, conditionValue);
		return cat;
	}

	@Override
	public Sell[] retrieveOnMultipleCond(Date fromdate, Date todate) {
		// TODO Auto-generated method stub
		return null;
	}
	public int getAutoGenratedKey()
	{
		 int key=super.getAutoGenratedKey(className,"autoitemCode") ;
		 return key;
	}
}
